using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Xml;

namespace LonCanvas
{
	public class DrawUtils
	{
		static Pen m_selectedPen = null;
		static public Pen SelectedPen
		{
			get
			{
				if (m_selectedPen == null)
				{
					m_selectedPen = new Pen(Color.Magenta, 1);
					m_selectedPen.DashStyle = DashStyle.Dash;
				}
				return m_selectedPen;
			}
		}
		static public void DrawNode(ICanvas canvas, UnitPoint nodepoint)
		{
			RectangleF r = new RectangleF(canvas.ToScreen(nodepoint), new SizeF(0, 0));
			r.Inflate(3, 3);
			if (r.Right < 0 || r.Left > canvas.ClientRectangle.Width)
				return;
			if (r.Top < 0 || r.Bottom > canvas.ClientRectangle.Height)
				return;
			canvas.Graphics.FillRectangle(Brushes.White, r);
			r.Inflate(1, 1);
			canvas.Graphics.DrawRectangle(Pens.Black, ScreenUtils.ConvertRect(r));
		}
		static public void DrawTriangleNode(ICanvas canvas, UnitPoint nodepoint)
		{
			PointF screenpoint = canvas.ToScreen(nodepoint);
			float size = 4;
			PointF[] p = new PointF[] 
			{
				new PointF(screenpoint.X - size, screenpoint.Y),
				new PointF(screenpoint.X, screenpoint.Y + size),
				new PointF(screenpoint.X + size, screenpoint.Y),
				new PointF(screenpoint.X, screenpoint.Y - size),
			};
			canvas.Graphics.FillPolygon(Brushes.White, p);
		}
	}



	
}
